<template>
  <div>
    <h1>添加角色资源</h1>
    <ul>
      <li v-for="i in roles">{{ i.NAME }}
        <router-link :to="{path:'/add_jszy2',query:{'id':i.id}}">
          配置资源
        </router-link>
      </li>
    </ul>
    <!--    <p>角色：<select v-model="form.role_id">-->
    <!--      <option v-for="i in roles" :value="i.id">{{ i.NAME }}</option>-->
    <!--    </select></p>-->
    <!--    <p>资源：<select v-model="form.resources_id">-->
    <!--      <option v-for="j in ziyuan" :value="j.id">{{ j.NAME }}</option>-->
    <!--    </select></p>-->
    <van-button style="background-color: azure" round @click="add">添加</van-button>


  </div>
</template>

<script>
export default {
  name: "add_jszy",
  data() {
    return {
      roles: [],
      ziyuan: [],
      form: {}
    }
  },
  methods: {
    getjszy() {
      this.$axios.get('/admin/roles').then(res => {
        if (res.data.code == 200) {
          this.roles = res.data.list1
          this.ziyuan = res.data.list2
        }
      })
    },
    add() {
      this.$axios.post('/admin/jszy', this.form).then(res => {
        if (res.data.code == 200) {
          alert('添加成功')
          this.form = {}

        }
      })


    }
  },
  mounted() {
    this.getjszy()
  }
}
</script>

<style scoped>

</style>
